import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AccessRecordVO, AccessRecordForm, AccessRecordQuery } from '@/api/dormitory/accessRecord/types';

/**
 * 查询宿舍出入记录列表
 * @param query
 * @returns {*}
 */

export const listAccessRecord = (query?: AccessRecordQuery): AxiosPromise<AccessRecordVO[]> => {
  return request({
    url: '/dormitory/accessRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询宿舍出入记录详细
 * @param id
 */
export const getAccessRecord = (id: string | number): AxiosPromise<AccessRecordVO> => {
  return request({
    url: '/dormitory/accessRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增宿舍出入记录
 * @param data
 */
export const addAccessRecord = (data: AccessRecordForm) => {
  return request({
    url: '/dormitory/accessRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改宿舍出入记录
 * @param data
 */
export const updateAccessRecord = (data: AccessRecordForm) => {
  return request({
    url: '/dormitory/accessRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除宿舍出入记录
 * @param id
 */
export const delAccessRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dormitory/accessRecord/' + id,
    method: 'delete'
  });
};
